import http from "../utils/http";
import qs from "qs";
//
/**
 *  @parms 请求地址
 *  @param 参数
 */
let resquest = "/API";

// 账号密码登陆
export function postPasLogin(data) {
  return http.post(`/un-auth-open/login`, data);
}

// 获取当前登录用户的详细信息
export function getUserInfo() {
  return http.get(`/rast-user/queryCurrentUserInfoRole`);
}

// 获取用户列表
export function getUserList(data) {
  return http.post(`/rast-user/queryUserList`, data);
}

// 删除指定用户
export function deleteUserById(id) {
  return http.get(`/rast-user/deleteUserById?userId=` + id);
}

// 查询角色列表
export function getRoleList(data) {
  return http.post(`/rast-role/queryRoles`, data);
}

// 修改用户角色
export function updateUserRole(data) {
  return http.post(`/rast-user-role/saveUpdateUserRole`, data);
}

//验证码登陆
export function postCodeLogin(email, code) {
  return http.post(
    `${resquest}/account/login_c?email=${email}&type=1&typeCode=${code}`
  );
}

//登陆获取邮箱验证码
export function postEmailCode(email) {
  return http.post(`${resquest}/auth/send?target=${email}&type=EMAIL_LOGIN`);
}

//注册获取验证码
export function postRegisterCode(email) {
  return http.post(`${resquest}/auth/send?target=${email}&type=EMAIL_SIGNUP`);
}

//注册账号
// export function postRegisterAccount(email, code) {
//     return http.post(`${resquest}/auth/check?type=EMAIL_SIGNUP&target=${email}&authCode=${code}`)
// }

//注册账号--基本信息
export function postRegisterAccount(params) {
  return http.post(`/un-auth-open/register`, params);
}

//获取当前用户基本信息
export function getAccountInfo() {
  return http.get(`${resquest}/account/info`);
}

//修改账户基本信息
export function saveChangeInfo(params) {
  return http.post(`${resquest}/account/update_info`, qs.stringify(params));
}

//修改基本信息 ----邮箱 获取验证吗
export function postChangeEmailCode(email) {
  return http.post(`${resquest}/auth/send?target=${email}&type=EMAIL_VALID`);
}

//修改基本信息 ----手机 获取验证吗
export function postChangePhoneCode(phone) {
  return http.post(`${resquest}/auth/send?target=${phone}&type=PHONE_VALID`);
}

//修改基本信息 ----验证邮箱
export function postChangeEmail(code, email) {
  return http.post(
    `${resquest}/account/update_email?authCode=${code}&email=${email}`
  );
}

//修改基本信息 ----验证手机
export function postChangePhone(code, phone) {
  return http.post(
    `${resquest}/account/update_phone?authCode=${code}&email=${phone}`
  );
}
//查询用户列表
export function queryUserList(data) {
  return http.post(`/rast-user/queryUserList`, data);
}

//查询指定用户信息、角色、菜单、品牌、银行账号
export function queryUserInfoRoleById(userId) {
  return http.get(`/rast-user/queryUserInfoRoleById?userId=` + BigInt(userId));
}

export function saveUpdateUserBank(data) {
  return http.post(`/rast-user-bank/saveUpdateUserBank`, data);
}

// 获取指定用户信息
export function getUserById(userId) {
  return http.get(`/rast-user/getUserById?userId=` + userId);
}

// 修改指定用户信息
export function editUserById(userId, userName) {
  return http.get(
    `/rast-user/editUserById?userId=` + userId + `&userName=` + userName
  );
}

// 获取所有账号邮箱
export function queryUserEmail() {
  return http.get(`/rast-user/queryUserEmail`);
}

// 发送验证码
export function sendVerifyCode(mailAddress , way, page) {
  return http.get(`/open/senMailVerifyCode?mailAddress=` + mailAddress + `&way=` + way + `&page=` + page);
}

// 核实验证码是否正确
export function checkingVerifyCode(email, code, way) {
  return http.get(`/open/checkingVerifyCode?email=` + email + `&code=` + code + `&way=` + way);
}

// 修改密码
export function editPassword(email,password) {
  return http.get(`/open/editPassword?email=` + email + `&password=` + password);
}

